package com.fulu.netty.luban.nio;

import java.nio.ByteBuffer;

/**
 * buffer也可以放其他类型，按顺序存取
 */
public class Demo5 {
    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(100);
        buffer.putChar('a');
        buffer.putDouble(12d);
        buffer.putInt(12);
        buffer.putLong(12L);
        buffer.putShort((short) 12);
        buffer.putFloat(12f);
        buffer.put((byte)'a');
        buffer.flip();
        System.out.println(buffer.getChar());
        System.out.println(buffer.getDouble());
        System.out.println(buffer.getInt());
        System.out.println(buffer.getLong());
        System.out.println(buffer.getShort());
        System.out.println(buffer.getFloat());
        System.out.println(buffer.get());
    }
}
